﻿using MediatR;
using T.Materials.Domain.Model;
using T.Materials.Read.API.ApplicationRead.Command.CountryCommand;
using T.Materials.Repository.MaterialsInterface;

namespace T.Materials.Read.API.ApplicationRead.CommandHandler.CountryCommand
{
    public class ShowCountryCommandHandler : IRequestHandler<ShowCountryCommand, List<Country>>
    {
        /// <summary>
        /// 
        /// </summary>
        protected readonly ICountryRepository countryRepository;

        public ShowCountryCommandHandler(ICountryRepository countryRepository)
        {
            this.countryRepository = countryRepository;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<Country>> Handle(ShowCountryCommand request, CancellationToken cancellationToken)
        {

            return await countryRepository.GetAllAsync();  
        }
    }
}
